package com.example.demo.controller;

import com.example.demo.domain.Cart;
import com.example.demo.services.CatalogService;
import com.example.demo.services.impl.NationalPolicyResult;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
//@SessionAttribute("Cart")
public class CartController {

    @Autowired
    CatalogService categoryService;
    @RequestMapping(value = "/cart",method = RequestMethod.GET)
    public NationalPolicyResult getCart(HttpSession Session){
        Cart cart = (Cart) Session.getAttribute("Cart");
        if(cart != null){
            return new NationalPolicyResult(0,"购物车",cart);
        }
        else {
            return new NationalPolicyResult(2,"没有购物车",null);
        }
    }

    @RequestMapping(value = "/cart/{itemID}",method = RequestMethod.PUT)
    public NationalPolicyResult insertItem(@PathVariable String itemID){
        return null;
    }

}
